home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / amiga / gui / mui / mui14-dv.lha / MUI / Developer / Autodocs / MUI_Notify.doc < prev    next >
Encoding:
Text File  |  1993-10-28  |  13.3 KB  |  465 lines

  1. TABLE OF CONTENTS
  2.  
  3. Notify.mui/Notify.mui
  4. Notify.mui/MUIM_CallHook
  5. Notify.mui/MUIM_Notify
  6. Notify.mui/MUIM_Set
  7. Notify.mui/MUIM_SetAsString
  8. Notify.mui/MUIM_WriteLong
  9. Notify.mui/MUIM_WriteString
  10. Notify.mui/MUIA_AppMessage
  11. Notify.mui/MUIA_HelpFile
  12. Notify.mui/MUIA_HelpLine
  13. Notify.mui/MUIA_HelpNode
  14. Notify.mui/MUIA_Revision
  15. Notify.mui/MUIA_UserData
  16. Notify.mui/MUIA_Version
  17. Notify.mui/Notify.mui
  18.  
  19.     Notify class is superclass of all other MUI classes.
  20.     It's main purpose is to handle MUI's notification
  21.     mechanism, but it also contains some other methods
  22.     and attributes useful for every object.
  23. Notify.mui/MUIM_CallHook
  24.  
  25.     NAME
  26.     MUIM_CallHook
  27.  
  28.     SYNOPSIS
  29.     DoMethod(obj,MUIM_CallHook,struct Hook *Hook, ULONG param1, /* ... */);
  30.  
  31.     FUNCTION
  32.     Call a standard amiga callback hook, defined by a Hook
  33.     structure. Together with MUIM_Notify, you can easily
  34.     bind hooks to buttons, your hook will be called when
  35.     the button is pressed.
  36.  
  37.     The hook will be called with a pointer to the hook
  38.     structure in a0, a pointer to the calling object in a2
  39.     and a pointer to the first parameter in a1.
  40.  
  41.     INPUTS
  42.     Hook       pointer to a struct Hook.
  43.     param1,... zero or more parameters. The hook function will
  44.                receive a pointer to the first parameter in
  45.                register a1.
  46.  
  47.     EXAMPLE
  48.  
  49.     standalone:
  50.  
  51.     DoMethod(obj,MUIM_CallHook,&hookstruct,13,42,"foobar","barfoo");
  52.  
  53.     within a notification statement:
  54.  
  55.     DoMethod(propobj,MUIM_Notify,MUIA_Prop_First,MUIV_EveryTime,
  56.              propobj,3,MUIM_CallHook,&prophook,MUIV_TriggerValue);
  57.  
  58.     prophook will be called every time the knob is moving and gets
  59.     a pointer to the knobs current level in a1.
  60. Notify.mui/MUIM_Notify
  61.  
  62.     NAME
  63.     MUIM_Notify
  64.  
  65.     SYNOPSIS
  66.     DoMethod(obj,MUIM_Notify,ULONG TrigAttr, ULONG TrigVal, APTR DestObj, ULONG FollowParams, /* ... */);
  67.  
  68.     FUNCTION
  69.     Add a notification event handler to an object. Notification
  70.     is essential for every MUI application.
  71.  
  72.     A notification statement consists of a source object,
  73.     an attribute/value pair, a destination object and a
  74.     notification method. The attribute/value pair belongs
  75.     to the source object and determines when the notification
  76.     method will be executed on the destination object.
  77.  
  78.     Whenever the source object gets the given attribute set to
  79.     the given value (this can happen because of the user
  80.     pressing some gadgets or because of your program explicitly
  81.     setting the attribute with SetAttrs()), the destination
  82.     object will execute the notification method.
  83.  
  84.     With some special values, you can trigger the notification
  85.     every time the attribute is changing. In this case, you
  86.     can include the triggering attributes value within the
  87.     notification method. See below.
  88.  
  89.     One big problem with notification are endless loops.
  90.     Imagine you have a prop gadget and want to show its
  91.     state with a gauge object. You connect MUIA_Prop_First
  92.     with MUIA_Gauge_Max and everything is fine, the gauge
  93.     gets updated when the user drags around the gadget. On
  94.     the other hand, if your program sets the gauge to a new
  95.     value, you might want your prop gadget to immediately
  96.     show this change and connect MUIA_Gauge_Max width
  97.     MUIA_Prop_First. Voila, a perfect endless loop.
  98.  
  99.     To avoid these conditions, MUI always checks new
  100.     attribute values against the current state and
  101.     cancels notification when both values are equal.
  102.     Thus, setting MUIA_Prop_First to 42 if the prop
  103.     gadgets first position is already 42 won't trigger
  104.     any notification event.
  105.  
  106.     INPUTS
  107.     TrigAttr     attribute that triggers the notification.
  108.  
  109.     TrigValue    value that triggers the notification. The
  110.                  special value MUIV_EveryTime makes MUI execute
  111.                  the notification method every time when
  112.                  TrigAttr changes. In this case, the special
  113.                  value MUIV_TriggerValue in the notification
  114.                  method will be replaced with the value
  115.                  that TrigAttr has been set to. You can use
  116.                  MUIV_TriggerValue up to four times in one
  117.                  notification method.
  118.  
  119.     DestObj      object on which to perform the notification
  120.                  method.
  121.  
  122.     FollowParams number of following parameters. If you e.g.
  123.                  have a notification method with three parts
  124.                  (maybe MUIM_Set,attr,val), you have to set
  125.                  FollowParams to 3. This allows MUI to copy
  126.                  the complete notification method into a
  127.                  private buffer for later use.
  128.  
  129.     ...          following is the notification method.
  130.  
  131.     EXAMPLE
  132.  
  133.     /*
  134.     ** Every time when the user releases a button
  135.     ** (and the mouse is still over it), the button object
  136.     ** gets its MUIA_Pressed attribute set to FALSE.
  137.     ** Thats what a program can react on with notification,
  138.     ** e.g. by openening a window.
  139.     */
  140.  
  141.     DoMethod(buttonobj,MUIM_Notify,
  142.        MUIA_Pressed, FALSE,                /* attribute/value pair */
  143.        windowobj,                          /* destination object   */
  144.        3,                                  /* 3 following words    */
  145.        MUIM_Set, MUIA_Window_Open, TRUE);  /* notification method  */
  146.  
  147.     /*
  148.     ** Lets say we want to show the current value of a
  149.     ** prop gadget somewhere in a text field:
  150.     */
  151.  
  152.     DoMethod(propobj,MUIM_Notify,      /* notification is triggered   */
  153.        MUIA_Prop_First, MUIV_EveryTime /* every time the attr changes */
  154.        textobj                         /* destination object */
  155.        4,                              /* 4 following words  */
  156.        MUIM_SetAsString, MUIA_Text_Contents,
  157.        "value is %ld !", MUIV_TriggerValue);
  158.        /* MUIV_TriggerValue will be replaced with the
  159.           current value of MUIA_Prop_First */
  160.  
  161.     /*
  162.     ** Inform our application when the user hits return
  163.     ** in a string gadget:
  164.     */
  165.  
  166.     DoMethod(stringobj,MUIM_Notify,
  167.        MUIA_String_Acknowledge, MUIV_EveryTime,
  168.        appobj, 2, MUIM_Application_ReturnID, ID_FOOBAR);
  169. Notify.mui/MUIM_Set
  170.  
  171.     NAME
  172.     MUIM_Set
  173.  
  174.     SYNOPSIS
  175.     DoMethod(obj,MUIM_Set,ULONG attr, ULONG val);
  176.  
  177.     FUNCTION
  178.     Set an attribute to a value. Normally, you would set
  179.     attributes with intuition.library SetAttrs() or with
  180.     the OM_SET method as with any other boopsi objects.
  181.     But since these calls need a complete tag list, not
  182.     just a single attribute/value pair, they are not
  183.     useful within a MUIM_Notify method.
  184.  
  185.     INPUTS
  186.     attr  attribute you want to set.
  187.     val   value to set the attribute to.
  188.  
  189.     EXMAPLE
  190.     DoMethod(strobj,MUIM_Set,MUIA_String_Contents,"foobar");
  191.     and
  192.     SetAttrs(strobj,MUIA_String_Contents,"foobar",TAG_DONE);
  193.     are equal.
  194.  
  195.     SEE ALSO
  196.     MUIM_SetAsString, MUIM_Notify
  197. Notify.mui/MUIM_SetAsString
  198.  
  199.     NAME
  200.     MUIM_SetAsString
  201.  
  202.     SYNOPSIS
  203.     DoMethod(obj,MUIM_SetAsString,ULONG attr, char *format, ULONG val, /* ... */);
  204.  
  205.     FUNCTION
  206.     Set a (text kind) attribute to a string. This can be useful
  207.     if you want to connect a numeric attribute of an object with
  208.     a text attribute of another object.
  209.  
  210.     INPUTS
  211.     attr    attribute to set.
  212.     format  C like formatting string, remember to use "%ld" !
  213.     val,... one or more paremeters for the format string.
  214.  
  215.     EXAMPLE
  216.  
  217.     stand alone:
  218.  
  219.     DoMethod(txobj,MUIM_SetAsString,MUIA_Text_Contents,
  220.              "My name is %s and I am %ld years old.",name,age);
  221.  
  222.     within a notification statement:
  223.  
  224.     DoMethod(propobj,MUIM_Notify,MUIA_Prop_First,MUIV_EveryTime,
  225.              txobj,4,MUIM_SetAsString,MUIA_Text_Contents,
  226.              "prop gadget shows %ld.",MUIV_TriggerValue);
  227.  
  228.     SEE ALSO
  229.     MUIM_Set, MUIM_Notify
  230. Notify.mui/MUIM_WriteLong
  231.  
  232.     NAME
  233.     MUIM_WriteLong
  234.  
  235.     SYNOPSIS
  236.     DoMethod(obj,MUIM_WriteLong,ULONG val, ULONG *memory);
  237.  
  238.     FUNCTION
  239.     This method simply writes a longword somewhere to memory.
  240.     Although this seems quite useless, it might become handy
  241.     if used within a notify statement. For instance, you could
  242.     easily connect the current level of a slider with some
  243.     member of your programs data structures.
  244.  
  245.     INPUTS
  246.     val    - value to write
  247.     memory - location to write the value to
  248.  
  249.     EXAMPLE
  250.  
  251.     /* Let the slider automagically write its level to a variable */
  252.  
  253.     static LONG level;
  254.  
  255.     DoMethod(slider,MUIM_Notify,MUIA_Slider_Level,MUIV_EveryTime,
  256.        slider,3,MUIM_WriteLong,MUIV_TriggerValue,&level);
  257.  
  258.     SEE ALSO
  259.     MUIM_WriteString, MUIM_Notify
  260. Notify.mui/MUIM_WriteString
  261.  
  262.     NAME
  263.     MUIM_WriteString
  264.  
  265.     SYNOPSIS
  266.     DoMethod(obj,MUIM_WriteString,char *str, char *memory);
  267.  
  268.     FUNCTION
  269.     This method simply copies a string somewhere to memory.
  270.     Although this seems quite useless, it might become handy
  271.     if used within a notify statement. For instance, you could
  272.     easily connect the current contents of a string gadget
  273.     with some member of your programs data structures.
  274.  
  275.     Note: The string is copied with strcpy(), you must assure
  276.               that the destination points to enough memory.
  277.  
  278.     INPUTS
  279.     str    - string to copy
  280.     memory - location to write the value to
  281.  
  282.     EXAMPLE
  283.  
  284.     static char buffer[256];
  285.  
  286.     DoMethod(string,MUIM_Notify,MUIA_String_Contents,MUIV_EveryTime,
  287.        string,3,MUIM_WriteString,MUIV_TriggerValue,buffer);
  288.  
  289.     SEE ALSO
  290.     MUIM_WriteLong, MUIM_Notify
  291. Notify.mui/MUIA_AppMessage
  292.  
  293.     NAME
  294.     MUIA_AppMessage -- [..G], struct AppMessage *
  295.  
  296.     FUNCTION
  297.     When your window is an AppWindow, i.e. you have set the
  298.     MUIA_Window_AppWindow attribute to TRUE, you will be able
  299.     to get AppMessages by listening to MUIA_AppMessage.
  300.     Whenever an AppMessage arrives, this attribute will
  301.     be set to a pointer to that message.
  302.  
  303.     MUIA_AppMessage is object specific. You can e.g. set up
  304.     different notifications for different objects in your window,
  305.     they will only get exectued when icons are dropped over the
  306.     specific object.
  307.  
  308.     If you wait on MUIA_AppMessage with a window object, your
  309.     notify will always get executed when icons are dropped on
  310.     the window.
  311.  
  312.     Notes:
  313.  
  314.     - You should use the MUIM_CallHook method to call a
  315.       hook function when an AppMessage arrives (see below).
  316.       The pointer to the AppMessage is only as long as the
  317.       notification method is executed.
  318.  
  319.     - AppWindows are only possible on the workench screen.
  320.  
  321.  
  322.     EXAMPLE
  323.  
  324.     /* Call the AppMsgHook when an icon is dropped on a listview */
  325.  
  326.     DoMethod(lvobj,MUIM_Notify,MUIA_AppMessage,MUIV_EveryTime,
  327.              lvobj,3,MUIM_CallHook,&AppMsgHook,MUIV_TriggerValue);
  328.  
  329.     /* Call the AppMsgHook when an icon is dropped on the window */
  330.  
  331.     DoMethod(winobj,MUIM_Notify,MUIA_AppMessage,MUIV_EveryTime,
  332.              winobj,3,MUIM_CallHook,&AppMsgHook,MUIV_TriggerValue);
  333.  
  334.     SEE ALSO
  335.     MUIA_Window_AppWindow, MUIA_Application_DropObject, MUIM_CallHook
  336. Notify.mui/MUIA_HelpFile
  337.  
  338.     NAME
  339.     MUIA_HelpFile -- [ISG], STRPTR
  340.  
  341.     FUNCTION
  342.     This attribute allows defining an AmigaGuide style file
  343.     to be displayed when the user requests online help.
  344.  
  345.     When the HELP button is pressed, MUI tries to obtain
  346.     MUIA_HelpFile from the current object (the one under
  347.     the mouse pointer). If MUIA_HelpFile is not defined,
  348.     MUI continues asking the parent object for this
  349.     attribute (usually a group, but remember: the parent
  350.     of a windows root object is the window itself, the
  351.     parent of a window is the application).
  352.  
  353.     When a non NULL MUIA_HelpFile is found, the same procedure
  354.     is applied to MUIA_HelpNode and MUIA_HelpLine. Then MUI
  355.     puts the application to sleep and displays the file at
  356.     the position specified width MUIA_HelpNode and/or MUIA_HelpLine.
  357.  
  358.     This behaviour allows you e.g. to define one MUIA_HelpFile
  359.     for your application object and different help nodes
  360.     and lines for your applications windows and/or gadgets.
  361.  
  362.     EXAMPLE
  363.  
  364.     ApplicationObject,
  365.        ...
  366.        MUIA_HelpFile, "progdir:myapp.guide",
  367.        ...,
  368.        SubWindow, WindowObject,
  369.           MUIA_Window_Title, "Prefs Window",
  370.           ...,
  371.           MUIA_HelpNode, "prefs-section",
  372.           ...,
  373.           End,
  374.  
  375.        SubWindow, WindowObject,
  376.           MUIA_Window_Title, "Play Window",
  377.           ...
  378.           MUIA_HelpNode, "play-section",
  379.           ...
  380.           WindowContents, VGroup,
  381.              ...,
  382.              Child, StringObject,
  383.                 MUIA_HelpNode, "play-string",
  384.                 ...,
  385.                 End,
  386.              End,
  387.           End,
  388.        End;
  389.  
  390.     In this case, the user will get the prefs-section chapter
  391.     of "myapp.guide" when he requests help in the Prefs window,
  392.     the play-string chapter when he requests help over the
  393.     string gadget in the Play window or the play-section
  394.     chapter somewhere else in the Play window.
  395.  
  396.     SEE ALSO
  397.     MUIA_HelpNode, MUIA_HelpLine
  398. Notify.mui/MUIA_HelpLine
  399.  
  400.     NAME
  401.     MUIA_HelpLine -- [ISG], LONG
  402.  
  403.     FUNCTION
  404.     Define a line in a help file specified with MUIA_HelpFile.
  405.  
  406.     SEE ALSO
  407.     MUIA_HelpFile, MUIA_HelpNode
  408. Notify.mui/MUIA_HelpNode
  409.  
  410.     NAME
  411.     MUIA_HelpNode -- [ISG], STRPTR
  412.  
  413.     FUNCTION
  414.     Define a node in a help file specified with MUIA_HelpFile.
  415.  
  416.     SEE ALSO
  417.     MUIA_HelpFile, MUIA_HelpLine
  418. Notify.mui/MUIA_Revision
  419.  
  420.     NAME
  421.     MUIA_Revision -- [..G], LONG
  422.  
  423.     FUNCTION
  424.     Get the revision number of an objects class. Although
  425.     MUIA_Revision is documented at notify class, you will
  426.     of course receive the revision number of the objects true
  427.     class.
  428.  
  429.     EXAMPLE
  430.     strobj = MUI_NewObject(MUIC_String,...,TAG_DONE);
  431.         ...
  432.     get(strobj,MUIA_Version ,&v);
  433.     get(strobj,MUIA_Revision,&r);
  434.     printf("String class version %ld.%ld\n",v,r);
  435.  
  436.     SEE ALSO
  437.     MUIA_Version
  438. Notify.mui/MUIA_UserData
  439.  
  440.     NAME
  441.     MUIA_UserData -- [ISG], ULONG
  442.  
  443.     FUNCTION
  444.     A general purpose value to fill in any kind of information.
  445. Notify.mui/MUIA_Version
  446.  
  447.     NAME
  448.     MUIA_Version -- [..G], LONG
  449.  
  450.     FUNCTION
  451.     Get the version number of an objects class. Although
  452.     MUIA_Version is documented at notify class, you will
  453.     of course receive the version number of the objects true
  454.     class.
  455.  
  456.     EXAMPLE
  457.     strobj = MUI_NewObject(MUIC_String,...,TAG_DONE);
  458.         ...
  459.     get(strobj,MUIA_Version ,&v);
  460.     get(strobj,MUIA_Revision,&r);
  461.     printf("String class version %ld.%ld\n",v,r);
  462.  
  463.     SEE ALSO
  464.     MUIA_Revision
  465.